package com.glsc.ngateway.common.base.repo.mysql.gateway.platform;


import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.FlowFormVendorRateMain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.validation.constraints.NotBlank;
import java.util.List;

@Repository
public interface FlowFormVendorRateMainRepo extends JpaRepository<FlowFormVendorRateMain, Integer>, JpaSpecificationExecutor<FlowFormVendorRateMain> {
    /**
     * 根据流程Id检索表单
     */
    FlowFormVendorRateMain findByProcessId(@NotBlank String processId);

    /**
     * 更新流程状态，常用语流程结束标志的更新
     */
    @Modifying
    @Query(value = "update t_gw_flow_form_vendor_rate_main set status=:status where process=:processId ", nativeQuery = true)
    Integer updateFlowFormStatus(@NotBlank String processId, @NotBlank String status);

    @Query(value = "select m from FlowFormVendorRateMain m where m.rateBelongDate = :year")
    public List<FlowFormVendorRateMain> queryByRateBelongDate(@NotBlank String year);
}
